<?php
	class XmlParser {
		/***
		
		***/
		function loadXML($filename) {
			$xml = simplexml_load_file($filename);
			if (!is_object($xml))
				throw new Exception('Error en la lectura del XML',1001);
			return $xml;
		}
		
		function askQuestion($varId) {
			$xml = simplexml_load_file("ask.xml");
			if (!is_object($xml)) {
				$xml = new SimpleXMLElement('<fileRootNode></fileRootNode>');				
				$xml->addAttribute('xmlns:xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
				$xml->addAttribute('xmlns:xsi:noNamespaceSchemaLocation', 'file:///C:/wamp/www/ssl/Prototipo/XML/schema.xsd');
				$askFor = $xml->addChild('AskFor');
			} else {
				$askFor = $xml->AskFor;
			}
			
			$property = $askFor->addChild('Property');
			$property->addChild('Module','0');
			$variable = $property->addChild('VarId',$varId);
			$variable->addAttribute('t','I');
			
			$xml->asXML("ask.xml");
		}
	}

?>
